﻿<Window x:Class="ComplexP2PSample.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:src="clr-namespace:C4F.VistaP2P.WPF;assembly=C4F_MediaViewPort"
    Title="Peer 2 Peer" Height="768" Width="1024" MinWidth="1024" MinHeight="768" MaxWidth="1024" MaxHeight="768" VerticalAlignment="Stretch" >
    <Window.Resources>
        <Style x:Key="TextBoxBaseStyle" TargetType="{x:Type TextBox}">
            <Setter Property="FontSize" Value="14"/>
            <Setter Property="Margin" Value="5"/>
        </Style>
    </Window.Resources>

    <Grid ShowGridLines="False">
        <!-- Define four rows: -->
        <Grid.RowDefinitions>
            <RowDefinition  Height="Auto" MinHeight="60" />
            <RowDefinition  Height="Auto" MinHeight="35" />
            <RowDefinition  Height="Auto" MinHeight="350" />
            <RowDefinition  Height="Auto" MinHeight="95" />
            <RowDefinition  Height="*"/>
            <!---Expansion row so buttons and bar stay at the bottom of the window-->
            <RowDefinition  Height="Auto" MinHeight="160" />
        </Grid.RowDefinitions>

        <!-- Define 2 cols: -->
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition Width="80" />
            <ColumnDefinition />
            <ColumnDefinition Width="1"/>
        </Grid.ColumnDefinitions>


        <!--Set up the background gradient -->
        <Grid.Background>
            <ImageBrush ImageSource="Images/bg.png"/>
        </Grid.Background>


        <StatusBar Grid.Row="1" Grid.ColumnSpan="3" FlowDirection="LeftToRight" Margin="0,5,0,0" Grid.Column="0" Height="30" HorizontalAlignment="Stretch" VerticalAlignment="Top" Width="Auto">

            <StatusBar.Background>
                <LinearGradientBrush EndPoint="0,1">
                    <GradientStop Offset="0" Color="Transparent" />
                    <GradientStop Offset=".2" Color="Transparent" />
                    <GradientStop Offset=".2" Color="Gray" />
                    <GradientStop Offset=".5" Color="Black" />
                    <GradientStop Offset=".5" Color="Black" />
                    <GradientStop Offset="1" Color="Gray" />
                </LinearGradientBrush>
            </StatusBar.Background>
            <StatusBarItem HorizontalAlignment="Left" Padding="0,-15,0,0"/>
            <StatusBarItem HorizontalAlignment="Left"/>
            <StatusBarItem/>

        </StatusBar>

        <!--Incoming text messages and outgoing messages-->
        <TextBox Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2"  Style="{StaticResource TextBoxBaseStyle}" FontFamily="Georgia" FontWeight="Heavy" Opacity="0.7"  Margin="15,5,15,0" Height="300" IsEnabled="True" Focusable="False" TextWrapping="Wrap"  VerticalScrollBarVisibility="Visible" FontStyle="Normal" Name="messageBox"/>
        <TextBox Grid.Row="3" Grid.Column="0"  FlowDirection="LeftToRight"  TextWrapping="Wrap"  AcceptsReturn="True"  Height="80" Margin="15,0,0,15"  Name="SendText" />


        <!--Audio/Video players-->
        <StackPanel Grid.Row="2" Grid.Column="2" Grid.ColumnSpan="2" HorizontalAlignment="Right">
            <!-- this stack panel pins us to the right hand side of the screen-->
            <Canvas Margin="0,20,80,0" Width="410" Height="330"/>
            <Border Margin="-60,-330,0,0"  Width="410" Height="330" BorderThickness="4" BorderBrush="Gray"/>
            <Canvas Margin="-20,-330,0,0" >
                <src:MediaElementViewPort Name="mMediaVideoViewPort"/>
                <src:MediaElementViewPort Name="mMediaAudioViewPort"/>
                <Image Name="mImage"  Margin="25,5,0,0" Width="400" Height="320" VerticalAlignment="Center"  HorizontalAlignment="Center" />
                <Label Margin="20,300,0,0"  Name="mBufferingVideo"/>
                <Label Margin="20,310,0,0"  Name="mBufferingAudio"/>
            </Canvas>
        </StackPanel>

        <StackPanel Grid.Row="3" Grid.Column="2" Grid.ColumnSpan="2" Height="80" Margin="0">
            <StackPanel Orientation="Horizontal" Margin="0">
                <Label Name="mFirstLine"/>
                <Label  Name="mFirstLineBlock"/>
            </StackPanel>
            <StackPanel Orientation="Horizontal"  Margin="0">
                <Label Name="mSecondLine"/>
                <Label Name="mSecondLineBlock"/>
            </StackPanel>
            <StackPanel Orientation="Horizontal" Margin="0">
                <Label Name="mThirdLine"/>
                <Label  Name="mThirdLineBlock"/>
            </StackPanel>
        </StackPanel>

        <Button Grid.Row="3" Grid.Column="1" HorizontalAlignment="Left" Margin="5" Height="40" Width="60" NumberSubstitution.CultureSource="Override" NumberSubstitution.Substitution="European" Name="btnSendText" Content="Send">
            <Button.Background>
                <LinearGradientBrush EndPoint="0,1">
                    <GradientStop Offset="0" Color="Transparent" />
                    <GradientStop Offset=".2" Color="Transparent" />
                    <GradientStop Offset=".5" Color="Red" />
                    <GradientStop Offset=".5" Color="Red" />
                    <GradientStop Offset="1" Color="PeachPuff" />
                </LinearGradientBrush>
            </Button.Background>
        </Button>


        <StackPanel FlowDirection="RightToLeft"  Grid.Row="5" Grid.Column="0" Grid.ColumnSpan="3">
            <Image Margin="0,0,0,0" Stretch="None" Source="Images/carousel_bar.png"/>
        </StackPanel>

        <!--UserName Join/Leave Network <Note this is out of order on the page flow, in order to have the expander appear on top of the black font bar..by putting it last it has a
        higher z order-->
        <StackPanel  Grid.ColumnSpan="3" Orientation="Horizontal" FlowDirection="LeftToRight" Margin="0,29.5,0,0" Grid.Column="0" Height="30" HorizontalAlignment="Right" Grid.Row="0" VerticalAlignment="Top" ClipToBounds="False">
            <Label Foreground="White" Height="25" Margin="10,0,0,5" HorizontalAlignment="Left"  VerticalAlignment="Top" Width="Auto" Content="User Name:"/>
            <!--<Canvas Width="20" Margin="5,5,5,0">
                Put a Canvas element around the expander to prevent clipping on grid and stack panels so we can see the full list(Thanks: Windows Presentation Foundation Unleashed pg 172)
                <Expander Foreground="Black" Name="mExpand"  Width="auto"  Height="auto" ClipToBounds="False" >
                    <ListBox Name="mMRULists" ClipToBounds="False"/>
                </Expander>
            </Canvas>-->
            <TextBox Name="textBoxUserName"    Opacity=".6" Height="25"  HorizontalAlignment="Left"  VerticalAlignment="Top" Width="119"/>

            <Label Foreground="White" Height="25" Margin="10,0,0,5"   HorizontalAlignment="Left"  VerticalAlignment="Top" Width="Auto" Content="Network:"/>
            <TextBox Name="textBoxNetworkName"  Opacity=".6" Height="25"  HorizontalAlignment="Left"  VerticalAlignment="Top" Width="119"/>

            <Label Foreground="White" Height="25"   Margin="10,0,0,5" HorizontalAlignment="Left"  VerticalAlignment="Top" Width="Auto" Content="Password:"/>
            <TextBox Name="textBoxPassword" Opacity=".6" Height="25"  HorizontalAlignment="Left"  VerticalAlignment="Top" Width="119"/>

            <Button Name="btnJoinNetwork" ToolTipService.ShowOnDisabled="True" ToolTip="Enter a UserName and Network Name in order to Join or create a network" Opacity=".8" Foreground="White" Height="25"   Margin="5,0,0,5" NumberSubstitution.CultureSource="Override" NumberSubstitution.Substitution="European" VerticalAlignment="Top" Width="96" Content="Join Network">

                <Button.Background>
                    <LinearGradientBrush EndPoint="0,1">
                        <GradientStop Offset="0" Color="PeachPuff" />
                        <GradientStop Offset=".5" Color="Red" />
                        <GradientStop Offset=".5" Color="Red" />
                        <GradientStop Offset="1" Color="PeachPuff" />
                    </LinearGradientBrush>
                </Button.Background>
            </Button>
            <Label Name="lblStatus" Foreground="White" Height="25" Width="100"></Label>
        </StackPanel>
        <!--Hide the regular buttons-->
        <Canvas Margin="-540,0,0,0">

            <Image Name="noArt"  Source="Images/album-art-none.png"></Image>

            <Button FontSize="18" Padding="0,-30,0,0"  Margin="0,-0,0,0" Width="120" Height="30"  NumberSubstitution.CultureSource="Override" NumberSubstitution.Substitution="European" VerticalAlignment="Bottom"  Name="mSendPicture" >
                <Button.Background>
                    <LinearGradientBrush EndPoint="0,1">
                        <GradientStop Offset="0" Color="PeachPuff" />
                        <GradientStop Offset=".5" Color="Red" />
                        <GradientStop Offset=".5" Color="Red" />
                        <GradientStop Offset="1" Color="PeachPuff" />
                    </LinearGradientBrush>
                </Button.Background>
                <StackPanel ClipToBounds="False">
                    <Canvas Width="120" Height="23" ClipToBounds="False">
                        <Image ClipToBounds="False"  Source="Images/sendpic.png"></Image>
                        <Label Margin="45,8,0,0"  Foreground="White" Height="30">Picture</Label>
                    </Canvas>
                </StackPanel>
            </Button>

            <Button Name="mSendAudio" FontSize="18" Padding="0,-40,0,0"  Margin="-0,0,0,0" Width="120" Height="30"  NumberSubstitution.CultureSource="Override" NumberSubstitution.Substitution="European" VerticalAlignment="Bottom" >
                <Button.Background>
                    <LinearGradientBrush EndPoint="0,1">
                        <GradientStop Offset="0" Color="PeachPuff" />
                        <GradientStop Offset=".5" Color="Red" />
                        <GradientStop Offset=".5" Color="Red" />
                        <GradientStop Offset="1" Color="PeachPuff" />
                    </LinearGradientBrush>
                </Button.Background>
                <StackPanel ClipToBounds="False">
                    <Canvas Width="120" Height="23" ClipToBounds="False">
                        <Image ClipToBounds="False"  Source="Images/headphone.png"></Image>
                        <Label Name="mAudioLabel" Margin="50,12,0,0" Foreground="White" Height="40">Audio</Label>
                    </Canvas>
                </StackPanel>
            </Button>


            <Button Name="mSendVideo" FontSize="20" Padding="0,-40,0,0"  Margin="-0,-0,0,0" Width="120" Height="30"  NumberSubstitution.CultureSource="Override" NumberSubstitution.Substitution="European" VerticalAlignment="Bottom" >
                <Button.Background>
                    <LinearGradientBrush EndPoint="0,1">
                        <GradientStop Offset="0" Color="PeachPuff" />
                        <GradientStop Offset=".5" Color="Red" />
                        <GradientStop Offset=".5" Color="Red" />
                        <GradientStop Offset="1" Color="PeachPuff" />
                    </LinearGradientBrush>
                </Button.Background>
                <StackPanel ClipToBounds="False">
                    <Canvas Width="120" Height="23" ClipToBounds="False">
                        <Image ClipToBounds="False"  Source="Images/filmstrip.png"></Image>
                        <Label Name="mVideoLabel" Margin="50,12,0,0" Foreground="White" Height="40">Video</Label>
                    </Canvas>
                </StackPanel>
            </Button>

            <Button Name="mSendFile" Foreground="White" FontSize="21" Padding="0,-40,0,0"  Margin="-0,0,0,0"  Width="120" Height="30"  NumberSubstitution.CultureSource="Override" NumberSubstitution.Substitution="European" VerticalAlignment="Bottom" >
                <Button.Background>
                    <LinearGradientBrush EndPoint="0,1">
                        <GradientStop Offset="0" Color="PeachPuff" />
                        <GradientStop Offset=".5" Color="Red" />
                        <GradientStop Offset=".5" Color="Red" />
                        <GradientStop Offset="1" Color="PeachPuff" />
                    </LinearGradientBrush>
                </Button.Background>
                <StackPanel ClipToBounds="False">
                    <Canvas Width="120" Height="23" ClipToBounds="False">
                        <Image ClipToBounds="False"  Source="Images/sendfile.png"></Image>
                        <Label Margin="60,10,0,0"  Height="40" Foreground="White">File</Label>
                    </Canvas>
                </StackPanel>
            </Button>
        </Canvas>

        <Viewport3D Grid.Row="5" Grid.Column="4"  Margin="-480,-120,0,0" MouseDown="OnButtonViewPortMouseDown" MouseMove="OnButtonViewPortMouseMove" MouseEnter="OnButtonViewPortMouseEnter" MouseLeave="OnButtonViewPortMouseLeave" Height="280" Width="400"  Name="buttonViewport" ClipToBounds="True" >
            <Viewport3D.Camera>
                <PerspectiveCamera
        FarPlaneDistance="100"
        LookDirection="0,-.2,-4"
        UpDirection="0,1,0"
        NearPlaneDistance="1"
        Position="0,8,4"
        FieldOfView="70" />
            </Viewport3D.Camera>
            <ModelVisual3D>
                <ModelVisual3D.Content>
                    <AmbientLight Color="White"/>
                </ModelVisual3D.Content>
            </ModelVisual3D>
        </Viewport3D>
        <Canvas Name="ComponentCanvas" Grid.Row="2"   Height="100" Margin="110.057,36,132.76,0" VerticalAlignment="Top">
            <my:NetworkManager Height="40" Width="40" Name="networkManager1" xmlns:my="clr-namespace:C4F.VistaP2P.WPF.Network;assembly=C4F_P2PWPFControls" Canvas.Left="8" Canvas.Top="3.691" Picture="{Binding ElementName=pictureControl1}" File="{Binding ElementName=fileControl1}" Chat="{Binding ElementName=chatControl1}" Video="{Binding ElementName=mediaVideoControl}" Audio="{Binding ElementName=mediaAudioControl}" UserName="{Binding ElementName=textBoxUserName}" NetworkName="{Binding ElementName=textBoxNetworkName}" Password="{Binding ElementName=textBoxPassword}" SignInButton="{Binding ElementName=btnJoinNetwork}" StatusValue="{Binding ElementName=lblStatus}"></my:NetworkManager>
            <my:ChatControl    Height="40" Width="40" Name="chatControl1" xmlns:my="clr-namespace:C4F.VistaP2P.WPF.Chat;assembly=C4F_P2PWPFControls"  SendButton="{Binding ElementName=btnSendText}" MessageLog="{Binding ElementName=messageBox}" SendText="{Binding ElementName=SendText}" Canvas.Left="63" Canvas.Top="3.691"></my:ChatControl>
            <my:FileControl    Height="40" Width="40" Name="fileControl1" xmlns:my="clr-namespace:C4F.VistaP2P.WPF.File;assembly=C4F_P2PWPFControls"  SendFileButton="{Binding ElementName=mSendFile}" Canvas.Left="121.313" Canvas.Top="5.691"></my:FileControl>
            <my:PictureControl Height="40" Width="40" Name="pictureControl1" xmlns:my="clr-namespace:C4F.VistaP2P.WPF.Picture;assembly=C4F_P2PWPFControls" SendPictureButton="{Binding ElementName=mSendPicture}" FileName="{Binding ElementName=mFirstLineBlock}" TitleName="{Binding ElementName=mSecondLineBlock}" PictureBox="{Binding ElementName=mImage}" Canvas.Left="167.627" Canvas.Top="5.691" ></my:PictureControl>
            <my:MediaControl   Height="40" Width="40" Name="mediaVideoControl"  xmlns:my="clr-namespace:C4F.VistaP2P.WPF.Media;assembly=C4F_P2PWPFControls"  SendMediaButton="{Binding ElementName=mSendVideo}" LineOneMetaDataValue="{Binding ElementName=mFirstLineBlock}" LineTwoMetaDataValue="{Binding ElementName=mSecondLineBlock}" LineThreeMetaDataValue="{Binding ElementName=mThirdLineBlock}" Canvas.Left="121.313" Canvas.Top="53"></my:MediaControl>
            <my:MediaControl   Height="40" Width="40" Name="mediaAudioControl"  xmlns:my="clr-namespace:C4F.VistaP2P.WPF.Media;assembly=C4F_P2PWPFControls" Canvas.Left="55" Canvas.Top="53" SendMediaButton="{Binding ElementName=mSendAudio}" LineOneMetaDataValue="{Binding ElementName=mFirstLineBlock}" LineTwoMetaDataValue="{Binding ElementName=mSecondLineBlock}" LineThreeMetaDataValue="{Binding ElementName=mThirdLineBlock}"></my:MediaControl>
        </Canvas>
    </Grid>



</Window>
